﻿<html DIR="LTR" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
  <head>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8" />
    <META NAME="save" CONTENT="history" />
    <title>Using Parameter Metadata</title>
    
    <link rel="stylesheet" type="text/css" href="../local/Classic.css">
      
    </link>
    
    <script src="../local/script.js">
      
    </script><script src="../local/script_main.js">&amp;nbsp;</script>
  </head>
  <body>
    <!--Topic built:09/24/2007 09:01:38-->

    
    
    
    
    
    
    
    
    
    <div id="header">
      <table width="100%" id="topTable"><tr>
          <td align="left">
            <span id="headerBold">Using Parameter Metadata</span>
          </td>
          <td align="right">
            
          </td>
        </tr></table>
      
      
      
    </div>
    <div id="mainSection">
      
        
        
		<font color="DarkGray"><!-- [This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]<br/>[Documentation built on $$TIMESTAMP$$]  --> </font> <p /> <p />
	
        <div id="introductionSection" class="section">
    <p>To query a <a href="a8481c06-fbba-432b-8c69-4f4619c20ad4.htm">SQLServerPreparedStatement</a> or a <a href="30710a63-c05d-47d9-9cf9-c087a1c76373.htm">SQLServerCallableStatement</a> object about the parameters that they contain, the Microsoft SQL Server 2005 JDBC Driver implements the <a href="546290e0-9411-4a2b-aa36-61251e70e9cf.htm">SQLServerParameterMetaData</a> class. This class contains numerous fields and methods that return information in the form of a single value. </p>
    <p>To create a <b>SQLServerParameterMetaData</b> object, you can use the <a href="c2876dec-ce29-4b61-9d74-ec3173b8cba5.htm">getParameterMetaData</a> methods of the <b>SQLServerPreparedStatement</b> and <b>SQLServerCallableStatement</b> classes.</p>
    <p>In the following example, an open connection to the SQL Server 2005 AdventureWorks sample database is passed in to the function, the <b>getParameterMetaData</b> method of the <b>SQLServerCallableStatement</b> class is used to return a <b>SQLServerParameterMetaData</b> object, and then various methods of the <b>SQLServerParameterMetaData</b> object are used to display information about the type and mode of the parameters that are contained within the HumanResources.uspUpdateEmployeeHireInfo stored procedure.</p>
    <div class="sampleCode"><span codeLanguage="other"><pre>public static void getParameterMetaData(Connection con) {
   try {
      CallableStatement cstmt = con.prepareCall("{call HumanResources.uspUpdateEmployeeHireInfo(?, ?, ?, ?, ?)}");
      ParameterMetaData pmd = cstmt.getParameterMetaData();
      int count = pmd.getParameterCount();
      for (int i = 1; i &lt;= count; i++) {
         System.out.println("TYPE: " + pmd.getParameterTypeName(i) + " MODE: " + pmd.getParameterMode(i));
      }
      cstmt.close();
   }
   catch (Exception e) {
      e.printStackTrace();
   }
}
</pre></span></div>
    <div style="margin: .5em 1.5em .5em 1.5em"><b>Note: </b>
      There are some limitations when using the <b>SQLServerParameterMetaData</b> class with prepared statements. The JDBC driver supports SELECT, DELETE, INSERT, and UPDATE statements. However, these statements should not contain subqueries. In addition, the JDBC driver also supports using the IN, IS, and LIKE predicates. For search conditions, the JDBC driver supports using the IS, &lt;, &gt;, LIKE, &gt;=, &lt;=, NOT IN, &lt;&gt;, !&gt;, !&lt;, and != comparative operators. The FREETEXT operator is not supported.<p />
    </div>
  </div><span id="seeAlsoSpan"><h1 class="heading">See Also</h1></span><div id="seeAlsoSection" class="section" name="collapseableSection"><a href="5cfb35d4-ddcd-40a2-8091-f29cddc32552.htm">Handling Metadata with the JDBC Driver</a><br /><br /></div><!--[if gte IE 5]>
			<tool:tip element="seeAlsoToolTip" avoidmouse="false"/><tool:tip element="languageFilterToolTip" avoidmouse="false"/><tool:tip element="roleInfoSpan" avoidmouse="false"/>
		<![endif]-->
      <div id="footer" class="section">
        
		<hr />
		
		<span id="fb" class="feedbackcss">
			
			
		</span>
		
		<a href="9bad553b-9e70-4696-8499-2e35f772a1e0.htm">
			
			© 2007 Microsoft Corporation. All rights reserved.
		</a>
 	
	
      </div>
    </div>
  </body>
</html>